package com.micro.user.service.impl;

import com.micro.model.Order;
import com.micro.model.User;
import com.micro.user.client.OrderServiceClient;
import com.micro.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class UserServiceImpl implements IUserService {

    private final OrderServiceClient orderServiceClient;

    public UserServiceImpl(OrderServiceClient orderServiceClient) {
        this.orderServiceClient = orderServiceClient;
    }

    @Override
    public User getUserById(Long id) {
        User user = new User();
        user.setId(id);
        user.setUsername("xiaoBei");
        System.out.println("----------------");
        return user;
    }

    @Override
    public Order getOrderById(Long id) {
        return orderServiceClient.getOrderById(id);
    }

//    @Autowired
//    private RestTemplate restTemplate;

//    public String getUserInfo() {
//        return restTemplate.getForObject("http://orer-service/orders/1", String.class);
//    }
}
